<template>
	<view>
		<uni-calendar :start-date="'2012-6-14'" :end-date="'2022-6-30'"
			:selected="selected" @change="change" />
		<view class="con" v-for="(item,index) in aa" :key="index">
			<view class="left">
				<text v-if="item.allDay=='1'">全天</text>
				<text v-else>
					{{item.startTime.slice(-8)}} 开始 {{item.endTime.slice(-8)}} 结束
				</text>
			</view>
			<view class="right">
				{{item.title}} &nbsp; <u-icon name="arrow-right" style="margin: 2rpx 0 0 5rpx;"></u-icon>
			</view>
		</view>
		<view class="create">
			<navigator url="/pages/doplan/doplan">
				<u-icon name="plus"></u-icon>
				新建日程
			</navigator>
		</view>
	</view>
</template>

<script>
	import {
		getPlan,getPlans
	} from "@/api/api.js"
	
	export default {
		data() {
			return {
				selected: [],
				date:"",
				aa:[]
			}
		},
		onLoad(e) {
			console.log(e)
			this.date=e.date
		},
		mounted() {
			this.plan()
			this.getPlanss(Date.now())
		},
		methods: {
			change(e) {
				console.log(e);
				this.getPlanss(+new Date(e.fulldate))
			},
			async plan(data){
				let res=await getPlan({
					date:new Date().toLocaleString().replace(/\//g, "-")
				})
				console.log(res)
				res.result.forEach(item=>{
					this.selected.push({
						date:item.startTime.slice(0,10)
					})
				})
			},
			async getPlanss(data){
				let res=await getPlans({
					date:data
				})
				console.log(res)
				this.aa=res.result
			}
		}
	}
</script>

<style lang="scss">
	.con {
		width: 100%;
		display: flex;
		padding: 35rpx;
		justify-content: space-between;
		border: 1rpx solid #d0d0d0;
		border-left: none;
		border-right: none;

		.left {
			width: 200rpx;
			border-right: 6rpx solid #007AFF;
		}

		.right {
			flex: 1;
			display: flex;
			justify-content: flex-end;
			align-items: center;
		}
	}

	.create {
		width: 100%;
		padding: 35rpx;
		color: #afafaf;
	}
</style>
